Tried to make code little easier to understand