Writing heap class