Trouble with GridLayout.WorldToCell

public class TerrainInformations : MonoBehaviour {
public GridLayout grid;
private void Update()
{
Vector3 mousePos = Camera.main.ScreenToViewportPoint(Input.mousePosition);
Vector3Int wTCMousePos = grid.WorldToCell(mousePos);
Debug.Log(wTCMousePos);
}
}

Hi guys,
I am having trouble with Grids and Tilemaps. This code should output the values of the coordinates in the grid, but everytime I run the game the debug.log outputs the values of the position of the world, not the cell coordinates. The var grid is assigned in the inspector to a Grid component (the one used by Tilemaps). What am I doing wrong?
Thanks

My bad, what I had to use was ScreenToWorldPoint, not ScreenToViewportPoint.