added visualization when targetDirection is no longer in scanRange; minor generalizations applied