Version 2.0 with exception handling and additional checks