error CS1525: Unexpected symbol `public' Urgent help needed!!

So I can’t find what has cause this error or to be specific why it is an unexpected symbol… :confused: Pls help!! error line: public void SetSpeed(float modifier)…

using UnityEngine;
using System.Collections;

public class PlayerMotor : MonoBehaviour 
{
	private CharacterController controller;
	private Vector3 moveVector;

	private float speed = 10.0f;
	private float verticalVelocity = 0.0f;
	private float gravity = 5.0f;
		
	private float animationDuration = 3.0f;

	// Use this for initialization
	void Start () {
		controller = GetComponent<CharacterController> ();
	}

	// Update is called once per frame
    void Update () {

		if (Time.time < animationDuration) 
		{
			controller.Move (Vector3.forward * speed * Time.deltaTime);
			return;
		}

		moveVector = Vector3.zero;

		if (controller.isGrounded) 
		{
			verticalVelocity = -0.5f;
		} 
		else
		{
			verticalVelocity -= gravity * Time.deltaTime;
		}

		// X - Left and Right
		moveVector.x = Input.GetAxisRaw("Horizontal") * speed;

        // Y - Up and Down
		moveVector.y = verticalVelocity;

		// Z - Forward and Backward
		moveVector.z = speed;

		controller.Move (moveVector * Time.deltaTime);

		**public** void SetSpeed(float modifier)
		{
			speed = 10.0f + modifier;
		}
	}

You’re trying to define a function inside update by the looks of it. You need to learn some better formatting. You need to do that after update’s }