fixed some console errors from undefined var by moving into first function.Still not working, no contact with API, but no console errors.