working version / tests