apply Darron's new code