changed wrong order of function call