New funcion and bugfix