Revise location check to enable the program to run correctly