some updates to my r script, unfinished