added onSelect function