Implemented basic solve() loop