Maybe add some comments here and there in this method to make it more readable for new comers.