added comments for readbility, removed console log of result