remove unnecessary AND operation
add option to select window function