Fixed database logic

Signed-off-by: shrimpboyho <new.joseph10@gmail.com>