try catch for TypeError