added better error handling to dao