slightly refactor