Fixed error from checking empty list