extract function defintions to functions.jl