See comment for better solution