More improved code cohesion; seperated out some duplicate logic