Refactored a little