cleaned it up, needs comments