Rewrite using table
Add in new stuff
merge fix