added exception handling to max results