Working B functionality ugly code