added try/catch snippet. fixed indentation on switch statement