adjusting select function in the database