replaced copy with const ref. removed temp var