a simplified version of the code