Created the pseudocod and main loops