added better exception handling and messages