refactor case block to make it more reusable