aligned with new implementation
added encoding
commenting