Added code that was posted from the hackforge forums