Final version with exception handling...