fixed bug: pop values when they're not needed