added a bunch of useful stuff, created two useful functions