optimize the constructor