Refactor nodes controller