implement algorithm  with go