Migrate to reference for correct execution order