Eliminated messy code, still seems to work.