added the ability of adding captions.
need to fix some bugs