diff --git a/src/shapes.js b/src/shapes.js
index 4cbb4d3adcd5b6e1baef259d3da2857d9ad31fff..08cb5ab21f1c820e24cb38ab4f4d53aacd471580 100644
--- a/src/shapes.js
+++ b/src/shapes.js
@@ -8,9 +8,9 @@ function sin(a) {
   return Math.sin(dtor(a))
 }
 
-const angleStep = 10
+const angleStep = 90
 const numAngleCells = 180 / angleStep
-const rhoMax = 1000
+const rhoMax = 10000
 
 const getDistance = (a, b) => {
   if (!(a && b)) return 0
@@ -87,7 +87,7 @@ function angleBetweenVectors(p1, p2) {
 }
 
 const LINE_ANGLE_THRESHOLD = Math.PI / 4
-const VECTOR_LEN_THRESHOLD = 400
+const VECTOR_LEN_THRESHOLD = 5
 
 function couldBeLine(points) {
   if (points.length < 2) return false
@@ -101,16 +101,15 @@ function couldBeLine(points) {
 
     const d2Len = vectorLength(d2)
 
-    if (
-      cumulativeThreshold < VECTOR_LEN_THRESHOLD &&
-      d2Len < VECTOR_LEN_THRESHOLD
-    ) {
-      cumulativeThreshold += d2Len
-      continue
-    }
-
     const angle = angleBetweenVectors(d1, d2)
     if (Math.abs(angle) > LINE_ANGLE_THRESHOLD) {
+      if (
+        cumulativeThreshold < VECTOR_LEN_THRESHOLD &&
+        d2Len < VECTOR_LEN_THRESHOLD
+      ) {
+        cumulativeThreshold += d2Len
+        continue
+      }
       return false
     }
   }
@@ -218,14 +217,21 @@ function recognizeRect(points, rectDetectionData) {
   }
 }
 
+const MAX_RHO_STEP = 50
+const MIN_RHO_STEP = 5
+
+function rhoStepForPoints(points) {
+  return points.length > 50 ? MAX_RHO_STEP : MIN_RHO_STEP
+}
+
 function recognizeLine(points) {
   if (!(points && points.length)) return {}
   const accum = Array(numAngleCells)
   const houghConfig = {
-    rhoStep: points.length > 30 ? 50 : 5,
+    rhoStep: rhoStepForPoints(points),
   }
   points.forEach((x) => constructHoughAccumulator(houghConfig, accum, ...x))
-  const angle = findMaxInHough(accum, points.length - 1)
+  const angle = findMaxInHough(accum, points.length - 10)
 
   if (angle !== undefined) {
     return {