Moved initialization up into the beginning