fix for IE<10

.apply was not working for IE<10 see comments in code