detection and scaling