extract methods and use empty? instead of size==0