Attempted to make code much more readable