solve function is working but strangely multiplies results to output which causes looong computation for more advanced examples