Streamlined the script after learning a few things from poopypants.net