putting all the code together