Fixed bug when not all records were returned, implement get record api function