Make onSubmit method private and refactor.