uncommented avg time function and corrected missing bracket