Fixed segfault bug in dao.cpp