refactored second case