Added snap to grid functionality