Optimize code for detecting mounts