refactor into ragios js library