Added condition to check for existing categories

Fixes #27