select: corrected the function ordering to match with corresponding c code