added file checker as a function