This method could be a lot cleaner if you extract each part into a new protected method