cleaned up the code, still doesn't work. Time to go back to trusty ole Matlab