changed method order to make code easier to read from top to bottom