now using exceptions for error handling