isValid fixed - no more problems with json encoding