first full working version, but needs a little more finishing