Reverted code refactoring that changed the logic