updated the check algorithm to properly deal with multiple files