Fixed the type errors, but it is still not correct.