90% done; needs a little tweaking