Bug fix

Tested partially!