My solution for coding challenge