src code follows the same code format as demo