Clean up the code in shift