Added shiftWithAlignment function.