added max items functionallity