first attempt, heavily influenced by awallace