protect clear from null pointer