update rotate code to handle more complicated alogorithm(still doesnt work)