refactor the following code:func (s *SpaceSession) endInactiveSession() {
	if !s.isActive() {
		time.Sleep(time.Duration(s.InactiveSessionTimeout) * time.Second)
		if !s.isActive() {
			s.Logger.Println("Ending inactive session")
			err := EndCobroSession(s.SessionID, "", "inactive_session")
			if err != nil {
				s.Logger.Printf("Error when closing cobro session: %s\n", err)
			}
		}
	}
}