fixed issue where data was being returned undefined