restructuring of parseDataToSql for better readability