added some error checking to new and initialize