functions for switching between tabs and spaces