added a lot of changes and new bugs