Added error checking for non numerical values
added for loop to convert array string to numbers
Removed for loop
added error checks for length of x and y arrays
Changed for loop to allow better handling of x and y arrays
fixed typo variable was missing a $