file handle bug fixed