algorithm works. Need to change the way position attribtes are stored