function now works properly, in future add error checking measures for excel spreadsheets