complete code, v1.0