Function to change stack