initial shifting algorithm