refactored to use common class technique.