Refactor generic dao layer