added a remove empty node method