started adding error handling