Simplifing getData() function