dynamic array sizing + little refactoring
limited and greedy array sizing tested