Added in extra sanity checks and split up the methods