More or less working version