Fixed up the subroutine