diagonal bugfix in distance check