better file management
added min_by/max_by support; still idiomatic. It can be improved.