optimising usage of data structures