Fixed bug in min / max checks