Add cheking for updates and refactor managing DB