Fix select function