Made the getSelected function useful