main loop added, zero note check added (is it correct?)