Working code -- to be cleaned
More updates