Split out into functions, now nothing is working