adjusting count function and size variable