Remove duplicate logic (refactoring)