refactoring: functions splitted to allow build-style code execution