fixed leak, code need cleanup