move funcs to utils.py
Fixed bug with growing arrays