Changed code to use grid