fixed relational variabble conflict and added to_json method