coord to box function