bug fixes, add dispatch function, rename wrap to chain, toarray to value