Fixed issue where commands were in wrong order