On a side note, it might not be a bad idea to eventually split up this method in smaller functions.