fixed grow function, as well as simplified some code and fixed small errors