Fixed bug in adding class names to elements