implements AStream class