fix bugs on ruby1.8.7