separate scanSurroundingSpaces method into separate check and commit methods