Better implementation of constructor