changed order of code