Committing the code provided by Erik