bug fix and new funct