added switching views functionality