add better exception handling