cleaned code and simplified model