Refactor to a better structure