changed order of functions