Changed chooseFile function