fixed bugs with fileMode