fixes #766 optimize

avoid loop if empty