passing state through functions

…