refactored some tab code