repaired lang logic