added most of the rest of the code for region calculation. Still need to combine all outside regions together