optimized a bit. wraped coords setting and value setting in one function