bug fix, and a bit more friendly