Started rearranging JS into more logical order