fix syntax errors in case / when