Added database logic