working on the apportion function