Fixed problem with use of 'endsWith' method on string (only worked in Firefox)