code refactoring
todo: arrange the preview width and height.