refactored focus operation to consolidate identical code