a try catch and an escape function should help prevent issues