Refactored things a little