MOD: refactor code