unedited old version minus ajax function