implemented #42 fully