for rails 4 and bug fixes