more code refactor