code is horrendous