porting back from honza repo