Added error catch for select statement