refactoring avr stuff