check for file availability
minor refactor