added activesupport
refactor typecasting