working version, few tests