original code for reference