compute case function