Updated some code to streamline it a bit