add database and clean code