this fixes work of the checkDirection function in Firefox