refactored code to be more modular
refactored - changed course manager queries to be more efficient.