seprated code for fetching from view and placed it in model