implemented the first 4 functions.