distance = distance - direction*8
maxdistance = 51000