clean code with functions and add JSON.Serializer