Created HMDD2 subroutine