some redundant code removed