fix get attachment function