'working' version
new exception handling