major rewrite and udpate