Check for key value before string replace