Rewrote exisiting code for star-quality