some modifications and fixing bugs