Need to fix min subroutine