modified is rotation algorithm