this chunk seems like it should be compressed into a regexp..