corrected incorrect pop/push order

fixed "minimum stack depth reached" error