Allocate resource only if necessary