Refactor code 84987676

https://www.pivotaltracker.com/story/show/84987676
https://www.pivotaltracker.com/story/show/84987678