encapsulate as function