improve preview ui
fixing js logic error
improving switching on automatic update