My much prettier function :)