code from posts one to five