handle some error message from DB and restructure a bit