finishing optimizing problem 3 and adding a shared functions library