fix buggy create-no-content-no-exising-file bug and refactor