simplified code and keep $appUrl as number.