updated select algorithm
minor fix