fixed bugs and updated main.ino