fixed multiple bugs and changing tabs issue