added builder class and fixed --state