added code for using procs in case statements