Fixed a bug, must add a test for it later