fix a constant var
refactoring and more clean code
refactoring db.c db.h