added comments so that the code is actually readable