Reverted code which works

Added intermediate_frame variable