Broke out into functions file, added domain check