changed way to check if the list empty