some refactoring of main :scan method, added returns to the execution blocks