Made the code more organized to make it more readable