fully ported but with fatal bug yet