added optional caption functionality