mostly functioning version
working version