Factorized code
Finished Database class