arranged functions in more logical order