Updated ui and added more js for handling state