Fix bug in API