Refactore calculateOccupancy in pkg/scheduler

This pull request make  `calculateOccupancy` use the value directly instead of getting the value by the index. 

greatly improve the readability of the `calculateOccupancy` function.