Added code I found from online

From berkeley.