cleaned up gwr function