wrong ordering of code