refactored all the stuff
update database instead of replacing it