major overhaul for version 5. simple rails 4 implementation