Fixed bugs in the getRecord function