abstract two functions