removing some code duplication

code reuse