Broke up into separate functions, added support for comments