Bug fix - clear function