slight changes in code structure