Fixed code duplication