Refixed the bug thats crashing the API

First commit to fix the bug: e0954993937bd178a47aaa85b68b9a27877a433c