working version but far from complete