removed magic numbers and added an ascii flow diagram at the top to explain the program logic