small bug in function selection