Rewrite with rotate function