updated functions to not to be a closure