bug fix in creating new file, together with some reorganization and decrease in nesting in push function