moved function to localize object