Updated with kripken's suggestions.