add error handling to select