Added location detection handling
Added try catch