adds beginning of MarkInvalid function
merges hopefully