reduced some of the logic