Fixed the deref function, now it passes all the test cases!