This method is very similar with https://github.com/Mirantis/astute/pull/37/files#L3R41. It will be good to separate a general part into new method.