This method does much more than it is supposed to