changed order of function definitions