changed error function to square error