fix bugs as recommended
check nil for tags