added rotate images and fixed rotate function