change order of some stuff to make it more efficent