Final implementation. Working code! :-)