Made the code compatiable between Java and C++