added check if the list is empty, show error