changes in model and controllers as per the comments in code review