Use cleaner code as suggested by sagemintblue