fixed bug with .having()