fixed/cleaned up arduino code