Fixed duplicate code