using 'each' function instead of 'map'
moved 'model' function definition
added 'toJSON' function to ViewModel