Moved file creation into helper itself
Fixed variable conflicts