updating script to RETURN data.frame, rather than write it