Add more checks for Case
Refactor code