Finally fixed check for orientation