Fixed code duplication.