Ported New Code from Old repo and updated with rend2