took out the stackoverflow solution because it made things worse