Fixing error introduced by last patch where bindings were lost

Like mentioned in issue #53 the new count function loses bindings causing a sql error. this patch fixes that.