more porting old code into cursor-based approach