added minimum function solution