Function for finding smallest number