public String outputFreeSlots(String[] users, Calendar cal) throws FileNotFoundException, IOException{
       String output = "";
       DBManager db = new DBManager();
       
       cal.set(cal.get(cal.YEAR),cal.get(cal.MONTH),1);
       cal.setFirstDayOfWeek(Calendar.MONDAY);
        int lastMonthCount = cal.get(cal.DAY_OF_WEEK) - 2;
        if(lastMonthCount < 0) lastMonthCount = 6;
        cal.add(Calendar.DAY_OF_MONTH,-lastMonthCount);
       ArrayList<Event> resultEvents = new ArrayList<Event>();
       ArrayList<Event> events = db.getEventsForUsers(users);
           
       for(int i = 0; i < 42; i++) {
           int count = 0;
           int currYear = cal.get(cal.YEAR);
           int currMonth = cal.get(cal.MONTH)+1;
           int currDay = cal.get(cal.DAY_OF_MONTH);
           String currDate = "" + currDay + "/" + currMonth + "/" + currYear;
           //for each period between 8am and 8pm
           for(int j=8; j<20; j++) {
                for(Event e : events)
                {
                    if(e.getStartDateDay() == cal.get(Calendar.DAY_OF_MONTH) && e.getStartDateMonth() == cal.get(Calendar.MONTH)+1 && e.getStartDateYear() ==  cal.get(Calendar.YEAR) && e.getStartTime() == j)
                    {
                        count++;
                    }

                }
               //now add the results for this period to the list of events
               int type = (count==0)?0:3;
               
               resultEvents.add(new Event("", ""+count,
                                        currDate, currDate, j, j+1, "", "", "",type));
               count = 0;
           }
           cal.add(Calendar.DAY_OF_MONTH,1);
           System.out.println(currDate);
       }
       cal.add(Calendar.MONTH,-1);
       return outputTimetable(cal, resultEvents);
    }