todo: merge both try/catch into a single one