Did some refactoring
Added database