reimplemented state.jl and products.jl with new design