Merge dynamic and static arrays to one class, updated algorithm