added better onclick handling