some improvements. still not final