added email alerts and finished basic functionality