solved cleaningup in Java and C