added correct file validation
file exists validation and some cleanup