add correct caption handling
refactor