Modified so that it works for rails 2.3.x