Code cleanup on db_select