Bug fix, need to add a test for it later