first working version, needs some tuning