Added exception handling to the methods.