I don't know what's wrong with my solution, it works for different inputs. Your help is much appreciated. thanks