Moved over some reusable code