bug fixes

added models fixes  some bugs and refactor