Adapted to comply with the second round of comment by @oskarwiksten