added some improvements I think