Refactored shifter function