Made from sample code and comments