fixed bug with clear() function