changed manhatton algorithm (silly me)