Implementation of factory