Removed redundant check in distance calculation