createFile refactored