Wrote functions. Still need to comment.