movin some util functions into the closure and into the object