slight improvements in code structure