fixed an exception
try catch all exceptions to stop it crash Xcode
correctly handle instancetype