use factory for common functions