Changing magic numbers to representative variables
Renaming some variables and improving the comments