cleaned up 'count', added documentation