working away at the conversion from C# to java