modifications and bug fix