refactors code to be more succinct