compleated code V1