added proper file check