reduce code duplication and make explosion-function reusable