added some validation
some state with encoding and new name
working version