refactor scanSurroundingSpaces method