Move so it can be used elsewhere as well