Made original code neater