added case statement
working with local db