Enhanced stage step function by storing original function in temp first