working ugly solution