Filled in general logic, now need to fix bugs