Removing code duplication