removed distinct and added the where clause