Reording functions to be more logical