This whole block seems like code I've read elsewhere.  Try to not repeat.