after debugging and fixing a few problems