begin case refactor