fixing allocation bug in loadData()