Making solve function target number agnostic