solution to rotate list problem