updated code, and started move towards new logic