 
 extension SubjectDetailViewController: MFMailComposeViewControllerDelegate{
 	func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
-		NSLog("Dismissing mail view controller")
-		controller.dismiss(animated: true, completion: nil)
+        
+		print("Dismissing mail view controller")
+        controller.dismiss(animated: true, completion: nil)
+
+//        self.dismiss(animated: true, completion: nil)
 	}
 }
 

				emailController.addAttachmentData(data, mimeType: "text/csv", fileName: fileName)
				
			}
			present(emailController, animated: true, completion: nil)
		}catch{
			NSLog("Error exporting data, can't open realm: \(error)")
		}

			NSLog("Cannot export data, unable to send data")
			return
		}
        
        let emailController = MFMailComposeViewController()
        emailController.mailComposeDelegate = self
        emailController.setToRecipients([]) //I usually leave this blank unless it's a "message the developer" type thing
        emailController.setMessageBody("Data Attached", isHTML: false)

		
		do{
			let realm = try Realm()
            
			guard let profile = realm.object(ofType: Profile.self, forPrimaryKey: profileID) else{
				NSLog("Error exporting profile sessions, can't find profile")
				return
			}
            
            emailController.setSubject("Subject \(profile.subjectNumber) All Session Data")

			
			for session in profile.sessions{
				guard session.startTime != nil else{
					NSLog("Error exporting session, start time nil")
