Cleaned-up code