fix ordering of functions