code refactoring - firmata