logic almost done