improve style of elem code