It is most the same as https://github.com/Mirantis/astute/pull/41/files#L3R54. Maybe allocate common part into a separate method?