Adds some exception handling