modified data method to handle both get/post requests