cleaned up a few errors by changing the order of instantiation