Added error handling in lab 1.2