Added invalidate() function