move addressing code to seperate function