solved speed issue by loading all records from the beginning and store in the data structure to load afterward