refactor.
use utility functions.