reorganized code by separating database related methods. Added a singleton class (not complete yet) to change the global constant.