Refactor: extracted functions