Rework some of this so not so much duplicated codes