But can you put me in the right direction to achieve where I'm asking for with some modifications on the code i have?
No, I can't. I can't see anything wrong with it. I'd start with some debugging, to determine if rotate() is called at all. If not, you have one problem. If it is, you have another.