implementing a setSelected Method