getFile function more flexible