bug fix (Thanks to Paulo Moura)