updated with database logic