refactored lines 87-92