refactor to use struct