use isEmpty() instead of size() == 0