updated with some extra comments