Moved David's code to a separate file