added detect_platform() function