Updated and cleaned js for phases