workaround to not use stack-based variable-length arrays