solving collision and rotation problems