working version, before adding binary support