added support for optarguments. fixed file validation.