Fixed count() method not properly counting. This was causing some buttons to appear when they should not