added mutex ans typecasts at malloc and