working barbot code