poorly ported arduino code, or something