some restructureing, add wator code