file checking updated & refactored