Bug fix and changed to static instead of dynamic scheduling for efficiency