jerks in gameplay of doodlejump like game

hello everyone,I have been working on doodle jump like gameplay ,there are certain glitches popping up because of its jump,changing its layer according to the direction of velocity.Problem arises when it gets downward OR zero velocity inside the brick collider and changes its layer to that of brick.
void Update ()

	if (rigidbody2D.velocity.y < 0)
		this.layer = LayerMask.NameToLayer("brick");
		this.layer = LayerMask.NameToLayer("player");	}

Move this code from Update to FixedUpdate since it’s dealing with physics (the rigidbody).