added functionality to find minimum