fixed switching tabs null pointer error