used MAX_PICS constant instead of '500'