Cleaned up the if else statement in getMinIdx