moving code to sensible locations