added outsurced error handling functions