cleaned-up code