factor out the framwork stuff