task 2 and task 4 are solved with little help from google :D