limit and min function