moved some of the functionality from viewsto job