refactoring according neonstalwart's review