refactor to simpler structure