implemented the select method