Made the code work properly.