Possible working version of code