adding code from common package (why was this not here?
)