add a cleaner code which is much easier to understand