change os.path.realpath(".") to os.getcwd()
change preview to function
add debug mode