move code out of tested functions
fix
avoid adding array if empty