Dirty code but works fine.