added profile switch function and global struct.