corresponding changes to gpu version. here goes...