Code reduction thanks to @asturur