Fixed all four functions. Now working on errors and exceptions.