restructured some things, looks like it works!