updated and refactored code also partially implemented RR scheduling