structure: refactor duplicate code