first working version (not tested on tusci yet)