Added edge cases. Still need to run a few more tests.