Refactored a bit, merge me please!