refactor codes..