added count function. (might be buggy but need to get on beast