Moved collision if-check to a more efficient location