Added reference to where this code came from