add implementation for max