Should really initialise prevMode - if (!conn)