Make rotate method more efficient

Signed-off-by: Ilya Nelkenbaum <ilya@nelkenbaum.com>