Updated onClick function if checks to .length