This function looks pretty useful and might be used in other modules in future. So, could we move it into separate file to make it accessible for other modules?