fixed some bugs in DAO implementation