Removed repeated code from solver (incurs performance penalty)