Use reference and const to improve performance