further attempt to remove code duplication