converted to passing by const& and const functions