vastly simplifying code