Corrected Esbens code to reflect my changes