Got rid of some repeated code :)