fixed java function code