reduced code and fixed build errors