casting malloc is ugly and unnecessary