started porting plugin code