modified algo and hide some inside button