updated code and included model managing