Ed: test for list emptyness before use

thanks @skywave for the tips

fix #605