fixing lon/lat reversal and moving stem name construction into a function