work version and add some fixes