fixed bug in contact selection code