added new API & optimized query