Added comments and made variables more semantic