Updated with more seperation of concerns.