JC: added @erb_code and if loop in views. other changes.