several bug fix
fix factory function