further along refactoring towards more functional approach