minor code changes (more functional style)