Wrapped everything in a big function