refactory api views