added file validation code