small refactoring of function and console logs