Further streamlined the code