Added helper functions and modified comments.