Rearranged code a bit to make it more clear
Added logic for the expired courses