Added while loops and mode parsing