Fix bug with retrieving the selected record