updated model and code