add if-else block to handle solve state.