added some extra comments explaining stuff