Finished more or less working version