Refactor to make it easier to handle multiple codes