fixed code. runs properly