replaced code with Marks code