Big refactor on is_closed calculation