simplify file operation code