Fixed the 'ap' detection