It works, even if it's ugly
Works, more elegant solution