Rewrote using python