trying to fix my awful code