int idx = -1;
try
{
Page page = null;
//Check if the page is already in the buffer
Integer frame = index.get(id);
//If not then read the page from disk
if (frame == null)
{
idx = scheduler.getNextFrame();
page = new Page(id);
page.setBytes(fileSystem.read(id).getBytes());
//Remove the old page from the index
index.remove(frames[idx].getId());
//Inform the scheduler that the old page was replaced