began adding castle function