Made a few changes to make everything work correctly