messy but working wifly+node code