Tried to fix the check algorithm