The effect of heteroatomic substitutions on the band gap of polyacetylene and polyparaphenylene derivatives