Convert program so that it can be executed in reverse order