optimization: pass var's by const ref instead of value