fix bugs in model