debugged on 4x4 and fixed rotate function