modified some files to avoid repeated code sequences