pre-allocate when possible