Added functionality to handle record not found error