fixed input sanitization for selection loop. I commit too much;;