modified some files to avoid repeated code sequences

modified some files to avoid repeated code sequences