Tried to make code easier to understand