Rewrote visibility handler to be a lot more simple