Fix select_value function