Lab how to use state with function