Detects margins around the rails