code with all cases