Made some changes that made the code work better