bugfix
refactor: extract function