using mutable arrays instead of [] for memory