added isEmpty function, additional commentary