Rewrote to use config file and be more magic