Porting code bug fix