refactor to be more simplified.