implement reasoning algorithm!!