Fixed a bug in case of coding negative degrees