finished added functions. debugging mode