refactor code
split cases