Simplify code

is_nesting_open returns a boolean with a equation value a true or false.
valid_close was using similar if statements I replaced all by a simple switch-case statement.