first working version. lots of features still needed!