Refactored in a way that suits me better