code with semi database, (not working)