A docblock explaining this function would be very helpful, and perhaps some inline comments.