added loops and switches