OSX compatibility 

Since OSX runs sed in a similar way to BSD, had to change the "-r" sed options to "-E"