working version before serious changes