better handling of errors and added a find function