Solved the task the proper way