modified some files to avoid repeated code sequences
Merge pull request #2 from lmb753/master

modified some files to avoid repeated code sequences